function [caldt_sorted , X_sorted] = sort_High_Low_fixed(caldt,X,portfolios)

% This function sorts the input variable 'X' into fixed buckets as defined by the
% variable 'portfolios'

X_temp = X(:,1);




for p = 1:length(portfolios)-1
    indx = and(X_temp >= portfolios(p) , X_temp < portfolios(p+1));      % locate and drop into buckets
    X_sorted{p,1} = X(indx,:);
    caldt_sorted{p,1} = caldt(indx,1);
end

end